package com.dingqb.ktdemo.oop


class OOPExtend {

}

fun main() {

    var student = Student("student1", 11);
    var teacher = Teacher("teacher1", 33);
    var teacher2 = Teacher("teacher1", 44, 1);
    println(student.toString());
    println(teacher.toString());
    println(teacher2.toString());
}

abstract open class AbsBase : Any() {

}

open class Person(name: String, age: Int) : AbsBase() {

}

open class Student : Person {
    constructor(name: String, age: Int) : super(name, age) {
        this.name = name
        this.age = age
    }

    var name: String = "";
    var age: Int = 0;
    override fun toString(): String {
        return "[name=$name,age=$age]"
    }
}

open class Teacher(name: String, age: Int) : Person(name, age) {
    constructor(name: String, age: Int, sex: Int) : this(name, age) {
        this.sex = sex;
    }

    var name = name;
    var age = age;
    var sex: Int = -1;
    override fun toString(): String {
        return "[name=$name,age=$age,sex=$sex]"
    }
}